{	V Open School Programming Olympiad
	Problem D
	Points: 79
}

var n,first,last,a,b,numb1,numb2,int1,int2,min1,min2:int64; code:integer; s,s1,s2,num1,num2:string;
procedure split(s,sub:string);
begin
s1:=copy(s,1,pos(sub,s)-1);
s2:=copy(s,pos(sub,s)+length(sub),length(s)-pos(sub,s)-length(sub)+1);
end;
begin
assign(input,'numeric.in');
assign(output,'numeric.out');
reset(input);
rewrite(output);
readln(s);
int1:=0;
int2:=0;
min1:=0;
min2:=0;
if s[1]='[' then first:=1 else first:=0;
if s[length(s)]=']' then last:=1 else last:=0;
delete(s,1,1);
delete(s,length(s),1);
split(s,', ');
num1:=s1;
num2:=s2;
if pos('/',num1)<>0 then begin
  split(num1,'/');
  val(s1,a,code);
  val(s2,b,code);
  numb1:=a div b + 1;
  if a<0 then min1:=1;
end else begin
  val(num1,numb1,code);
  if first=0 then inc(numb1);
  int1:=1;
end;
if pos('/',num2)<>0 then begin
  split(num2,'/');
  val(s1,a,code);
  val(s2,b,code);
  numb2:=a div b;
  if a<0 then min2:=1;
end else begin
  val(num2,numb2,code);
  if last=0 then dec(numb2);
  int2:=1;
end;
if (int1+int2=0) and (min1+min2=1) then inc(numb2);
if (int1+int2=1) and (min1+min2=0) then inc(numb2) ELSE 
inc(numb2);
writeln(numb2-numb1);
close(input);
close(output);
end.

